<?php
namespace Home\Controller;
use Think\Controller;
class BushuController extends Controller {
    public function index(){
        $appid = 'wx0a5423110c05daa2';
        $sessionKey = I('sessionKey');
        $encryptedData= I('encryptedData');
        $iv = I('iv');
        $data = '';
        if (strlen($sessionKey) != 24) {
			$data = 'sessionKey非法';
            $this->ajaxReturn($data,'JSON');
		}
        $aesKey=base64_decode($sessionKey);
        if (strlen($iv) != 24) {
			$data = 'ivAesIV非法';
            $this->ajaxReturn($data,'JSON');
		}
		$aesIV=base64_decode($iv);
		$aesCipher=base64_decode($encryptedData);
		$result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
        $dataObj=json_decode($result);
        if( $dataObj  == NULL ){
            $data = 'aes解密失败';
            $this->ajaxReturn($data,'JSON');
		}
		if( $dataObj->watermark->appid != $appid ){
			$data = 'aes解密失败';
            $this->ajaxReturn($data,'JSON');
		}
        $data = $dataObj->stepInfoList[30]->step;
		$this->ajaxReturn($data,'JSON');
    }
}